<?php
/**
 * Created by PhpStorm.
 * User: admin
 * Date: 2019/6/4
 * Time: 14:59
 */

namespace app\admin\controller;


use app\admin\model\CommonInfo;

class Common extends Base
{


    public function lists(){
        $data = CommonInfo::where('id',1)->find();
        $this->assign('data',$data);
        return $this->fetch();
    }

    public function save(){
        $post = input('post.');
        $data = [
            'image'=>$post['image'],
            'img'=>$post['img'],
            'company'=>$post['company'],
            'phone'=>$post['phone'],
            'number'=>$post['number'],
            'support'=>$post['support'],
            'name'=>$post['name'],
            'imgs'=>$post['imgs'],
            'url'=>$post['url']
        ];
        $ret = CommonInfo::update($data,['id'=>1]);
        if (!$ret){
            return json(['code'=>0,'msg'=>'保存失败']);
        }
        return json(['code'=>1,'msg'=>'保存成功']);
    }

}